<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsLinksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_links')) {
            Schema::create('cms_links', function (Blueprint $table) {
                $table->id();
                $table->string('name', 30)->default('')->comment('友情链接名称');
                $table->string('image', 100)->default('')->comment('友情链接图标');
                $table->string('url', 255)->default('')->comment('友情链接地址');
                $table->string('target', 10)->default('')->comment('友情链接打开方式');
                $table->string('rel', 50)->default('')->comment('链接与网站的关系');
                $table->string('description', 255)->default('')->comment('友情链接描述');
                $table->enum('status', ['yes', 'no'])->default('yes')->comment('状态;yes:显示;no:不显示');
                $table->integer('order')->default(0)->comment('排序,值越大权重越大');
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `cms_links` comment '友情链接表'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_links');
    }
}
